
<extend name="Public/layout"/>
<block name="head">
    <link rel="stylesheet" href="__PUBLIC__css/change-username.css">
<style type="text/css">
.footer{
    display: none;
}
</style>

 </block>
 <block name="main">
    <div class="form">
        <div class="form-group">
            <input type="text" id="nickname" size="6" placeholder="修改">
        </div>
        <div class="drop-msg">
            <p>六个字符以内，可由汉字、字母、数字组成</p>
        </div>
    </div>
    <div class="btn-wrapper">
        <a href="javascript:" onclick="sub()">保存</a>
    </div>
 <block name="js">
    <script type="text/javascript">
    function sub(){
        var nickname = $('#nickname').val();
		if(nickname.length>6){
			layer.open({
                content: '昵称长度不能超过6个字符'
                ,skin: 'msg'
                ,time: 2
            });
			return
		}
        if (nickname == '' || nickname == undefined || nickname == null) {
            layer.closeAll();
            layer.open({
                content: '请输入要修改的内容'
                ,skin: 'msg'
                ,time: 2
            });
            return
        }

        $.post('{:U("Person/change_nickname")}',{
            nickname:nickname,
        },function(res){
            console.log(res)
            if(res.err==0){
                layer.open({
                    content:res.msg
                    ,skin: 'msg'
                    ,time: 1
                    ,end:function(){
                        location.href="/Home/Person/setting";
                    }
                });
            }else{
                layer.open({
                    content:res.msg
                    ,skin: 'msg'
                    ,time: 1
                });

            }
        })
    }
    </script>
</block>